import { defineStore } from 'pinia';
import { getProductList, getExampleList, getComponetsList } from '@/api/product';

export const updataProductList = defineStore('product', {
  state: () => ({
    productList: [],
    exampleList: [],
    componentsList: [
      {
        productName: '',
      },
    ],
  }),
  actions: {
    async updataProduct(roleId: number) {
      this.productList = await getProductList(roleId);
    },
    async updataExample() {
      this.exampleList = await getExampleList();
    },
    async updataComponentsList(id: number, roleId: number) {
      this.componentsList = await getComponetsList(id, roleId);
    },
  },
});
